<!-- 工资发放 -->
<template>
  <div class="app-container">
    
    <label  >{{trainName}} </label>
    <el-table v-loading="loading" :data="trainList" >
      <el-table-column label="姓名" align="center" prop="userName" />
      <el-table-column label="身份证号" align="center" prop="userIdentityCard" />
      <el-table-column label="培训类型" align="center" prop="trainType"  :formatter="trainType" />
      <el-table-column label="部门名称" align="center" prop="sourceName" />
      <el-table-column label="合格" align="center" prop="trainQualified" :formatter="trainQualified" />
      <el-table-column label="考试分数" align="center" prop="examScore" :formatter="examScore"  />
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
import {detailList} from "../../../api/system/train";
import { getToken } from "@/utils/auth";
export default {
  name: "detail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      trainList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      inoutTable: false,
      // 状态数据字典
      statusOptions: [],
      // 基站编号
      postOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        trainId: this.$route.query.train.trainId,
      },
      trainName:this.$route.query.train.trainName,
       // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/salary/importData"
      },
      handleUpdate (row) {
            this.$router.push({
              path:'/salary/details',
              query: {
                salary: row
              }
            })
      }
    }
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询岗位列表 */
    getList() {
      this.loading = true;
      detailList(this.queryParams).then(response => {
        this.trainList = response.data;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 岗位状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    // 岗位状态字典翻译
    trainType(row, value) {
      if (row.trainType=="1") {
        return "安全培训"
      } else if (value == "2") {
        return "喊话记录"
      } else if (value == "3") {
        return "交底记录"
      } else {
        return "技能培训"
      }
    },
    examScore(row, value) {
      if (-1 ==row.examScore ) {
        return "未考试"
      } else  {
        return value
      }
    },
    trainQualified(row, value) {
      if (row.trainQualified === 1) {
        return "合格"
      } else  {
        return "不合格"
      }
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.postId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    
    /** 导出按钮操作 */
    handleExport() {
      this.$confirm('是否确认导出所有岗位数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportByDate();
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      exportTemplate().then(response => {
        this.download(response.msg);
      });
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
       this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    }


  }
};
</script>
